<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>微博舆情分析系统-微博KMeans聚类分析</title>
    <script src="https://unpkg.com/vue@3"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.7.2/axios.js"></script>
    <style>
       body {
      animation: blink 2s infinite alternate; 
    }

    @keyframes blink {
      0% {
        background-color: pink; 
      }

      100% {
        background-color: skyblue; 
      }
    }

    .content{
        width: 90%;
        max-width: 90%; /* 添加最大宽度以防止在大屏幕上变得过大 */
        height: 100%;
        background-color: #ffffff;
        box-sizing: border-box;
        border-radius: 5px;
        margin-left: 5%;
        margin-top: 20px;
    }
    .guidebar{
        display: flex;
        justify-content: space-evenly;
        width: 100%;
        max-width: 100%; /* 添加最大宽度以防止在大屏幕上变得过大 */
        height: 60px;
        background-color: rgb(221, 196, 240);
        box-sizing: border-box;
        border-radius: 5px;
    }

    .time{
        position: relative;
        display: flex;
        justify-content:flex-start;
        flex-direction: row;
        width: 100%;
        max-width: 100%; /* 添加最大宽度以防止在大屏幕上变得过大 */
        height: 50px;
        background-color: rgba(196, 240, 214, 0.863);
        box-sizing: border-box;
        border-radius: 5px;
    }

    .button0{
            margin: 10px 5px 0 5px;
            width: 120px;
            height: 30px;
            border-radius: 5px;
            font-size: 10px;
            font-weight: 600;
            cursor: pointer;
            text-align: center;
            background: none;
            color: #6e6e6e;
            border-style: none;
            box-shadow: 0 0 8px rgba(102, 102, 102, 0.5);
    }

    h6{
        margin:15px 10px 10px 125px;
        font-size: 15px;
        color:#6e6e6e;
      }

    .button{
            margin-top: 5px;
            width: 150px;
            height: 50px;
            border-radius: 5px;
            font-size: 10px;
            font-weight: 600;
            cursor: pointer;
            text-align: center;
            background: none;
            color: #6e6e6e;
            border-style: none;
            box-shadow: 0 0 8px rgba(102, 102, 102, 0.5);
    }
    .homecontent{
      margin-top: 30px;
    }
    .display{
        position: relative;
        width: 90%;
        max-width: 90%; /* 添加最大宽度以防止在大屏幕上变得过大 */
        height: 500px;
        background-color: #ffffff;
        box-sizing: border-box;
        border-radius: 5px;
        margin-left: 5%;
        margin-top: 40px;
        bottom: 10px;
        color: #ffffff;
        border-style: none;
        box-shadow: 0 0 8px rgba(102, 102, 102, 0.5);
        padding-left: 2%;
        padding-top: 15px;
        overflow: hidden;
    }

    .displayf{
        position: relative;
        display: flex;
        flex-direction:row;
        justify-content: space-around;
        width: 90%;
        max-width: 90%; /* 添加最大宽度以防止在大屏幕上变得过大 */
        height: 510px;
        background-color: #ffffff;
        box-sizing: border-box;
        border-radius: 5px;
        margin-left: 5%;
        margin-top: 40px;
        bottom: 10px;
        color: #ffffff;
        border-style: none;
        overflow: hidden;
    }
    
    .titlename{
        position: relative;
        right:1%;
        text-decoration:overline;
        text-align:center;
        font-size: 20px;
        color: black;
    }
    .halfdisplay{
        display: inline-block;
        width: 45%;
        max-width: 45%; /* 添加最大宽度以防止在大屏幕上变得过大 */
        height: 500px;
        margin-top: 5px;
        background-color: #ffffff;
        box-sizing: border-box;
        border-radius: 5px;
        color: #ffffff;
        border-style: none;
        box-shadow: 0 0 8px rgba(102, 102, 102, 0.5);
        padding-top: 15px;
    }
    
    .image-container {
  width: 90%;  /* 设置盒子的宽度 */
  height: 90%; /* 设置盒子的高度 */
  margin-left: 4%;
}
 
.image-container img {
  width: 100%; /* 图片宽度自适应盒子宽度 */
  height: 100%; /* 图片高度自适应盒子高度 */
  object-fit: contain;
}

    </style>
    

</head>

<body>
    <div class="content">

      <div class="time">
        <h6>选择时间范围</h6>
        <input type="date" id="start_time" class="button0">
        <input type="date" id="end_time" class="button0">
        <button onclick="startCrawler()" class="button0">确定</button>
      </div> 

        <div class="guidebar">
            <div>
                <button onclick="homepage()" class="button">首页</button>
                <button onclick="sentimentpage()" class="button">情感分析可视化</button>
                <button onclick="weibopage()" class="button">微博可视化</button>
                <button onclick="Kmeanspage()" class="button">微博KMeans聚类分析</button>
            </div>
            <div>
                <button onclick="exist()" class="button">退出登录</button>
                <button onclick="location.reload()" class="button">刷新</button>
            </div>
        </div>
            

          <div id="app">
        <div class="homecontent">
          <div class="display">
            <div class="titlename" >热点话题占比</div>
                    <div class="image-container">
                      <img src="https://test2022211.oss-cn-beijing.aliyuncs.com/%E5%89%8D%E5%8D%81%E4%B8%AA%E8%AF%9D%E9%A2%98%E7%9A%84%E6%AF%94%E4%BE%8B.png" alt="加载中" />
                      </div>
          </div>

          <div class="displayf">
          <div class="halfdisplay">
            <div class="titlename">词云图聚类1</div>
            <div class="image-container">
              <img id="Kmeansimage_2" alt="加载中" />
            </div>
          </div>
          <div class="halfdisplay">
            <div class="titlename">词云图聚类2</div>
            <div class="image-container">
              <img id="Kmeansimage_3" alt="加载中" />
            </div>
          </div>
        </div>
       </div>
        


    </div>


    <script>
        function homepage() {
      // 跳转到首页页面的逻辑
      window.location.href ='home.html';
        }
        function sentimentpage() {
      // 跳转到情感分析可视化页面的逻辑
      window.location.href ='sentiment.html';
        }
        function weibopage() {
      // 跳转到微博可视化页面的逻辑
      window.location.href ='weibo.html';
        }
        function Kmeanspage() {
      // 跳转到微博KMeans聚类分析页面的逻辑
      window.location.href ='Kmeans.html';
        }
        function exist() {
      // 跳转到登录页面的逻辑
      window.location.href ='login.html';
        }


        const app = Vue.createApp({
      data() {
        return {
          Kmeansimage_1: '',
          Kmeansimage_2: '',
          Kmeansimage_3: ''
        };
      },
      mounted() {
        this.getNextPicture('hot_time');
        this.getNextPicture('cloud');
        this.getNextPicture('cloud');
      },
      methods: {
        getNextPicture(directory) {
          axios.get(`http://10.21.249.41:8000/pictures/list/${directory}/`)
            .then(response => {
              if (directory === 'hot_time') {
                const Kmeansimage1 = 'http://10.21.249.41:8000' + response.data.url;
                document.getElementById('Kmeansimage_1').src = Kmeansimage1;
              } else if (directory === 'cloud') {
                const Kmeansimage2 = 'http://10.21.249.41:8000' + response.data.url;
                document.getElementById('Kmeansimage_2').src = Kmeansimage2;
                axios.get(`http://10.21.249.41:8000/pictures/list/${directory}/`)
                .then(response =>{
                  const Kmeansimage3 = 'http://10.21.249.41:8000' + response.data.url;
                  document.getElementById('Kmeansimage_3').src = Kmeansimage3;
                })
                
              }
            })
            .catch(error => {
              console.error('获取图片错误:', error);
            });
        },
      }
    });

    app.mount('#app');


        
        /*function loadImage() {
            loadKmeansImage_1();
            loadKmeansImage_2();
            loadKmeansImage_3();
    }

    function loadKmeansImage_1() {
            document.getElementById('Kmeansimage-1').src ='https://test2022211.oss-cn-beijing.aliyuncs.com/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240703020029.png';
      /*axios.get('http://your_backend_url')
     .then(response => {
        document.getElementById('homeimage-1').src = response.data;
      })
     .catch(error => {
        console.error('获取图片 URL 时出错:', error);
      });
    }

    function loadKmeansImage_2() {
            //document.getElementById('Kmeansimage-2').src ='https://test2022211.oss-cn-beijing.aliyuncs.com/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240703015834.png';
      axios.get('http://10.21.249.41:8000/pictures/list/')
     .then(response => {
      console.log(response.data);
        document.getElementById('Kmeansimage-2').src = 'http://10.21.249.41:8000'+response.data.url;
      })
     .catch(error => {
        console.error('获取图片 URL 时出错:', error);
      });
    }

    function loadKmeansImage_3() {
            //document.getElementById('Kmeansimage-3').src ='https://test2022211.oss-cn-beijing.aliyuncs.com/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240703020029.png';
      axios.get('http://10.21.249.41:8000/pictures/list/')
     .then(response => {
        document.getElementById('Kmeansimage-3').src = 'http://10.21.249.41:8000'+response.data.url;
      })
     .catch(error => {
        console.error('获取图片 URL 时出错:', error);
      });
    }*/

    function startCrawler(){
      alert('哈哈，大傻春，被骗了吧。');
    }

    </script>
    
</body>
</html>